package labox.innovation.gameserver.taskmanager;

import labox.innovation.config.Config;
import labox.innovation.gameserver.model.FuzeWorld;
import labox.innovation.gameserver.timer.Timer;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

/***
 * 现在统计
 * 
 * @author jacky
 * 
 */
public class AutoCountPlayersManager implements Runnable {
	protected static final Logger _log = LoggerFactory.getLogger(AutoCountPlayersManager.class.getName());

	private AutoCountPlayersManager() {
		/**
		 * 现在统计
		 */
		new Timer(Config.AUTO_COUNT_PLAYER_INTERVAL * 60 * 1000, true, this).start();
	}

	public static AutoCountPlayersManager getInstance() {
		return SingletonHolder._instance;
	}

	@SuppressWarnings("synthetic-access")
	private static class SingletonHolder {
		protected static final AutoCountPlayersManager _instance = new AutoCountPlayersManager();
	}

	@Override
	public void run() {
		try {
			if (_log.isInfoEnabled())
				_log.info("在线玩家数量:" + FuzeWorld.getInstance().getAllPlayersCount(), Config.SERVER_ID);
		} catch (Exception e) {
			// TODO: handle exception
		}

	}

}
